package com.mofeng.myshop.controller.admin;


import com.mofeng.myshop.domain.dto.SettingDto;
import com.mofeng.myshop.service.ISettingService;
import com.mofeng.myshop.until.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 网站基础设置 前端控制器
 * </p>
 *
 * @author MoFeng
 * @since 2024-04-14
 */
@RestController
@RequestMapping("/admin/setting")
@RequiredArgsConstructor
@Tag(name = "网站基础设置接口", description = "网站基础设置相关接口")
@PreAuthorize(value = "@permissionService.ROOT()")
public class SettingAdminController {

    private final ISettingService settingService;

    @Operation(summary = "获取网站基础设置列表")
    @GetMapping("/list")
    public R getListAdmin() {
        return settingService.getListAdmin();
    }

    @Operation(summary = "添加网站基础设置")
    @PostMapping("")
    public R addSetting(@RequestBody SettingDto settingDto) {
        return settingService.updateSetting(settingDto);
    }

    @Operation(summary = "修改网站基础设置")
    @PutMapping("")
    public R updateSetting(@RequestBody SettingDto settingDto) {
        return settingService.updateSetting(settingDto);
    }

    @Operation(summary = "删除网站基础设置")
    @DeleteMapping("")
    public R delSetting(@RequestParam("id") List<String> ids) {
        return settingService.delSetting(ids);
    }

}
